<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
  import util from '@/libs/util'
  import {
    merchantDetailUrl
  } from '@/utils/interface'
  export default {
    name: 'app',
    watch: {
      '$i18n.locale': 'i18nHandle'
    },
    created() {
      this.i18nHandle(this.$i18n.locale)
      this.getMerchantDetail()
    },
    methods: {
      i18nHandle(val, oldVal) {
        util.cookies.set('lang', val)
        document.querySelector('html').setAttribute('lang', val)
      },
      getMerchantDetail() {
        this.$get(merchantDetailUrl).then(res => {
          util.cookies.set('shopInfo', res.data.data)
          util.cookies.set('merchantId', res.data.data.id)
        })
      }
    }
  }
</script>

<style lang="scss">
  @import '~@/assets/style/public-class.scss';
  @import '~@/assets/style/css/common.css';
  @import '~@/assets/style/css/iconfont.css';
</style>
